/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.nii.qlks.BusinessLogicLayer;

import edu.nii.qlks.DataAccessLayer.MSSQLConnectUnit;
import edu.nii.qlks.DataTransferObject.ThamSoInfo;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.HashMap;

/**
 *
 * @author MARS_NHO
 */
public class ThamSoBLL {
    MSSQLConnectUnit _connect;
    ResultSet  _result;
 
    
    public ArrayList LayDS(String Condition, String OderBy) throws Exception{
        ArrayList vt = new ArrayList();
        
        _connect = edu.nii.qlks.BusinessLogicLayer.BusinessLogicAbstract.getConnection();
        _result = _connect.Select("THAMSO", Condition, OderBy);
        
        while (_result.next()){
            ArrayList vt_row = new ArrayList();
            vt_row.add(_result.getString(1));
            vt_row.add(_result.getString(2));
            vt.add(vt_row);
        }
        _connect.Close();
        return vt;
    }
    
    public ArrayList LayDS(String Condition) throws Exception{
         return LayDS(Condition, null);
    }
    
    public ArrayList LayDS() throws Exception{
        return LayDS(null);
    }
    
    public void Insert(ThamSoInfo thamSoInfo) throws Exception{
        _connect = edu.nii.qlks.BusinessLogicLayer.BusinessLogicAbstract.getConnection();
        HashMap<String, Object> map = new HashMap<>();
        map.put("SoKhachToiDa", thamSoInfo.getSoKhachToiDa());
        map.put("SoKhachTheoDonGia", thamSoInfo.getSoKhachTheoDonGia());
        _connect.Insert("THAMSO", map);
    }
    
     
//    public void Inserts(HashSet<ThamSoInfo> thamSoInfos) throws Exception{
//        for (ThamSoInfo thamSoInfo:thamSoInfos) {
//            this.Insert(thamSoInfo);
//        }
//    }
    
    public void Update(ThamSoInfo thamSoInfo) throws Exception{
        _connect = edu.nii.qlks.BusinessLogicLayer.BusinessLogicAbstract.getConnection();
        HashMap<String, Object> map = new HashMap<>();
        map.put("SoKhachToiDa", thamSoInfo.getSoKhachToiDa());
        map.put("SoKhachTheoDonGia", thamSoInfo.getSoKhachTheoDonGia());
        _connect.Update("THAMSO", map, null);
    }
    
//    public void Updates(HashSet<ThamSoInfo> thamSoInfos) throws Exception{
//        for (ThamSoInfo thamSoInfo:thamSoInfos){
//            this.Update(thamSoInfo);
//        }
//    }
    
//    public void Delete(ThamSoInfo thamSoInfo) throws Exception{
//        _connect = edu.nii.qlks.BusinessLogicLayer.BusinessLogicAbstract.getConnection();
//        _connect.Delete("THAMSO", "MaPhuThu = " + thamSoInfo.getMaPhuThu());
//    }
    
//    public void Deletes(HashSet<ThamSoInfo> thamSoInfos) throws Exception{
//         for (ThamSoInfo thamSoInfo:thamSoInfos){
//            this.Delete(thamSoInfo);
//        }
//    }
}
